<?php
/**
 * ucenter common class.
*/
class  AdminComm
{
    public static function init() 
	{
		if (! isset($_SESSION)) session_start();
    }
    
    /**
     * check is login yet....
     */
    public static function check() 
	{
		if ( ! isset($_SESSION['admin_id']) || $_SESSION['admin_id'] == ''
			|| ! isset($_SESSION['admin_name']) || $_SESSION['admin_name'] == ''
			|| ! isset($_SESSION['admin_email'])  || $_SESSION['admin_email'] == ''
			|| ! isset($_SESSION['admin_power'])  || $_SESSION['admin_power'] == ''
			|| ! isset($_SESSION['admin_agent']) || $_SESSION['admin_agent'] == '' )
			return FALSE;
		return TRUE;
    }
    
    public static function register( $_admin_id, $_admin_name, $_admin_email, $_admin_power) 
	{
		$_SESSION['admin_id'] = $_admin_id;
		$_SESSION['admin_name'] = $_admin_name;
		$_SESSION['admin_email'] = $_admin_email;
		$_SESSION['admin_power'] = admin_power;
		$_SESSION['admin_agent'] = $_SERVER['HTTP_USER_AGENT'];
    }
    
    public static function logout () 
	{
		$_SESSION['admin_id'] = '';
		$_SESSION['admin_name'] = '';
		$_SESSION['admin_email'] = '';
		$_SESSION['admin_power'] = '';
		$_SESSION['admin_agent'] = '';
    }
    
    public static function getAdminName()
	{
		return $_SESSION['admin_name'];
    }
    
    public static function getAID()
	{
		return $_SESSION['admin_id'];
    }
    public static function getAdminPower()
	{
		return $_SESSION['admin_power'];
    }
}